package com.xb.controller;

import com.xb.service.HomeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet("/home/*")
public class HomeController extends BaseController{

    private HomeService homeService=new HomeService();



    protected void index(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 查询今日注册用户/今日新增文章/今日发布会议等数据
        Map<String,Object> homeCount=homeService.findHomeCount();

        // 查询近七日的数据汇总信息
        List<List<Long>> homeDetail=homeService.findHomeDetail();

        Map<String,Object> returnMap = new HashMap();
        returnMap.put("homeCount",homeCount);
        returnMap.put("homeDetail",homeDetail);

        // 转换为JSON写出到前端
        writerObjToString(resp,returnMap);

    }



    }
